<div class="manage-user">
<div class="manage-user-atas">
	<div class="trans-log-atas-title ">List Ticket</div>
	<div class="trans-log-page"><?php
	echo ! empty($pagination) ? '' . $pagination . '' : '';
	?>
	</div>
</div>
<div class="manage-user-tengah">
	<div><a href="<?php echo site_url('createticket/ticket');?>"><img src="<?php echo base_url();?>images/ticket.png" border="none" /></a></div>
	<div class="manage-user-tengah-box">

<?php 
 if((isset($_SESSION['sys_admin']))||(isset($_SESSION['admin']))||(isset($_SESSION['intern_audit']))||(isset($_SESSION['second_consult']))||(isset($_SESSION['dept_pic']))) {
 
 /*$a =mysql_query("select * from ticket where status='' and severity_level='Critical' ");
 $x =mysql_fetch_object($a);
 if($x->severity_level == "Critical") {
 	echo "$x->severity_level";
	}*/
/*$d = date("Y-m-d H:i:s");
echo $d;
$x =mysql_query("select *from ticket where TIMEDIFF('open_datetime','2010-09-20 00:51:01')  order by ticket_id='15'");
$a =mysql_fetch_array($x);
echo $a['open_datetime'];*/
/* PROSES TRIGER
------------------------------------------------------------------------------------------------*/
$hasil= mysql_query("UPDATE ticket set status='Aktif' where  DATEDIFF(CURDATE(),open_datetime) > 1 and severity_level='Critical' and status='Open'");
$x= mysql_query("UPDATE ticket set status='Aktif' where  DATEDIFF(CURDATE(),open_datetime) > 2 and severity_level='Heigh' and status='Open'");
$x1 =mysql_query("UPDATE ticket set status='Aktif' where  DATEDIFF(CURDATE(),open_datetime) > 5 and severity_level='Medium' and status='Open' ");
$x2 =mysql_query("UPDATE ticket set status='Aktif' where  DATEDIFF(CURDATE(),open_datetime) > 7 and severity_level='Low' and status='Open'");
$x3 =mysql_query("UPDATE ticket set status='Aktif' where  DATEDIFF(CURDATE(),open_datetime) > 9 and severity_level='Note' and status='Open'");
/* END TRIGER
-----------------------------------------------------------------------------------------------*/
/*if($hasil) {
	echo "berhasil";
	} else {
		echo "data gagal";
		}*/



		
echo ! empty($h2_title) ? '<h2>' . $h2_title . '</h2>': '';
	echo ! empty($message) ? '<p class="message">' . $message . '</p>': '';
	echo ! empty($success) ? '<p class="message">' . $success . '</p>': '';
	
	$flashmessage = $this->session->flashdata('message');
	echo ! empty($flashmessage) ? '<p class="message">' . $flashmessage . '</p>': '';
	
				
	
	/*echo ! empty($table) ? $table : '';*/
	
	
}
?>

<table cellpadding="0" cellspacing="0" border="0" id="table" class="sortable" >
	<thead>
		<tr>
<th class="nosort"><h3>No</h3></th><th><h3>Ticket ID</h3></th><th><h3>Name</h3></th><th><h3>Open Datetime</h3></th><th><h3>Target Date</h3></th><th><h3>Close Date</h3></th><th><h3>Status</h3></th><th><h3>Sev Level</h3></th><th><h3>Prod</h3></th><th><h3>Actions</h3></th></tr>

		
	</thead>
	<tbody>
	<?php
		$w1 ="#bee1ff";
		$w2 ="#90ccff";
		$warna = $w1;
		$no =0;
		foreach($cek->result() as $cek) {
			if($warna==$w1) {
				$warna = $w2;
			} else {
				$warna = $w1;
			}
		$no ++;
	?>
	<tr bgcolor="<?php echo $warna;?>">
	  <td><?php echo ++$i;?></td>
      <td><?php echo $cek->ticket_id;?></td>
      <td><?php echo $cek->name;?></td>
      <td><?php echo $cek->open_datetime;?></td>
      <td><?php echo $cek->target_date;?></td>
      <td><?php echo $cek->close_date;?></td>
      <td><?php echo $cek->status;?></td>
      <td><?php echo $cek->severity_level;?></td>
      <td><?php echo $cek->product;?></td>
     
      <td><a href="<?php echo site_url('createticket/mngticket/update_process')."/".$cek->ticket_id;?>"><img src="<?php echo base_url();?>images/update.png" border="none"></a> &nbsp; <?php echo anchor('createticket/mngticket/download_ticket/'.$cek->ticket_id,'download ',array('class'=>'download','onclick'=>"return confirm('Anda yakin akan mendownload data ini?')"));?></td>
	</tr> 
<?php } ?>
		
	</tbody>
	
</table>

</div>
<script type="text/javascript" src="<?php echo base_url();?>js/sorter.js"></script>
<script type="text/javascript">
	var sorter = new TINY.table.sorter("sorter");
		sorter.head="heads";
		sorter.asc = "asc";
		sorter.desc = "desc";
		sorter.even = "evenrow";
		sorter.odd = "oddrow";
		sorter.evensel ="evenselected";
		sorter.oddsel ="oddselected";
		sorter.paginate= true;
		sorter.currentid ="currentpage";
		sorter.limited ="pagelimit";
		sorter.init("table",1);
</script>
	<div><a href="<?php echo site_url('createticket/ticket');?>"><img src="<?php echo base_url();?>images/ticket.png" border="none" /></a></div>
</div>
<div class="manage-user-bawah">
	<div class="trans-log-page2"><?php
	echo ! empty($pagination) ? '' . $pagination . '' : '';
	?></div>
</div>
</div>